//
//  NewsDetailViewController.m
//  tangshantongjiAPP
//
//  Created by yuntai on 2018/4/20.
//  Copyright © 2018年 yuntai. All rights reserved.
//

#import "NewsDetailViewController.h"

@interface NewsDetailViewController ()

@end

@implementation NewsDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if(self.isHidenNavi){
        UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenBoundWidth,   kNavigationHeight-44)];
        topView.backgroundColor = kNavigationColor;
        [self.view addSubview:topView];

        self.webView.frame = CGRectMake(2.5, 0, kScreenBoundWidth-5, kScreenBoundHeight-[UIApplication sharedApplication].statusBarFrame.size.height);
    }
    if(self.urlStr == nil){
        [self getdataTabitemFromServer];
    }
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if(self.isHidenNavi){
        [self.navigationController setNavigationBarHidden:YES];
    }
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    if(self.isHidenNavi){
        [self.navigationController setNavigationBarHidden:NO];
    }

}
-(void)getdataTabitemFromServer
{
    [HUDManager showLoadingHUDView:self.view];
    NSMutableDictionary *paramsDic = [NSMutableDictionary dictionary];
    [paramsDic setObject:self.newsId forKey:@"newsId"];
    [paramsDic setObject:kTokenID forKey:@"token"];
    weakself(self)
    [NetWork PostNetWorkWithUrl:@"api/news/getNewsDetail.ajax" with:paramsDic successBlock:^(NSDictionary *dic) {
        [HUDManager hideHUDView];
        NSDictionary *temgooddic = dic[@"data"];
        if (!temgooddic) {
            return ;
        }
       
        NSString *urlstr = temgooddic[@"content"];
        [weakself.webView loadHTMLString:urlstr?:@"" baseURL:[NSURL URLWithString:kAppWebRootUrl]];

        
        
    } FailureBlock:^(NSString *msg) {
        [HUDManager showWarningWithText:msg];
    } errorBlock:^(NSError *error) {
        
    }];
}


@end
